<template>
  <div class="property">
      <!-- 顶部搜索区域 -->
    <el-card>
      <el-form v-model="searchDate" ref="searchRef" label-width="100px" class="demo-ruleForm">
        <el-row class="demo-ruleForm-row">
          <el-col :span="6">
            <el-form-item label="项目名称" prop="name">
              <el-input placeholder="请输入招标项目名称" v-model="searchDate.name" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="招标编号" prop="info_number">
              <el-input placeholder="请输入招标编号" v-model="searchDate.info_number" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" >
            <div class="search_col">
              <el-button type="primary" size="mini" icon="el-icon-search">搜索</el-button>
              <el-button type="primary" size="mini" icon="el-icon-refresh" @click="resetForm">重置</el-button>
            </div>
          </el-col>
        </el-row>
        
      </el-form>
    </el-card>

    <!-- 卡片视图区域 -->
    <el-card class="card">
      <el-table
      :data="tableDate"
      :row-class-name="tableRowClassName"
      style="width: 100%"
      border
      ref="refTable"
      :header-cell-style="{
        'background-color': '#CBD9EC',
        color: '#fff',
        'font-weight': '400',
      }">
        <el-table-column width="60" label="序号" type="index"></el-table-column>
        <el-table-column prop="name" label="招标项目名称" width="240"></el-table-column>
        <el-table-column prop="info_number" label="招标编号"> </el-table-column>
        <el-table-column prop="institutions" label="代理机构"> </el-table-column>
        <el-table-column prop="responsibility" label="项目负责人"></el-table-column>
        <el-table-column label="操作" class="operation" width="100px">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="checkClick(scope.row)">财务详情</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.mount"
        :page-sizes="[1, 3, 6, 10]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 搜索数据
      searchDate: {
        name: '',
        // 开始时间
        value: '',
        // 结束时间
        value1: '',
        info_number: '',
        region: '',
        procurement_contact: '',
      },
      
      // 第一个表格
      tableDate: [
        {
          id: 1,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          info_number: 'JXRY2020-SR-002-JT(WZ)',
          institutions: '机构1',
          responsibility: '项目负责人',
        },
        {
          id: 2,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          info_number: 'JXRY2020-SR-002-JT(WZ)',
          institutions: '机构2',
          responsibility: '项目负责人',
        },
        {
          id: 3,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          info_number: 'JXRY2020-SR-002-JT(WZ)',
          institutions: '机构3',
          responsibility: '项目负责人',
        },
        {
          id: 3,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          info_number: 'JXRY2020-SR-002-JT(WZ)',
          institutions: '机构3',
          responsibility: '项目负责人',
        },
        {
          id: 5,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          info_number: 'JXRY2020-SR-002-JT(WZ)',
          institutions: '机构1',
          responsibility: '项目负责人'
        }
      ],

      // 分页数据
      page: {
        // 每页显示几条数据
        size: 6,
        // 当前页码值
        mount: 0,
      },
      // 总数据条数
      total: 6,
      isShow: false,
    }
  },
  methods: {
    // 隔行变色
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return 'warning-row'
      } else if (rowIndex === 3) {
        return 'success-row'
      }
      return ''
    },

    // 重置事件
    resetForm() {
      this.searchDate.name = '';
      this.searchDate.value = '';
      this.searchDate.value1 = '';
      this.searchDate.info_number = '';
      this.searchDate.region = '';
      this.searchDate.procurement_contact = '';
    },

    // 每页数据显示条数改变时触发
    handleSizeChange(newSize) {
      console.log(newSize)
    },
    // 页码值发生改变时触发
    handleCurrentChange(newPage) {
      console.log(newPage)
    },

    // 点击查看
    checkClick(row) {
      this.$router.push({path:`/approves/propertys`});
    },
  }
}
</script>

<style>
.property{
    padding: 20px;
}
</style>